package com.vmj.classfile.entity.constantinfo;

import com.vmj.classfile.ClassReader;
import com.vmj.classfile.entity.AbstractConstantInfo;
import com.vmj.classfile.entity.ConstantPool;

/**
 * Created by yangshoujun on 2017/8/6 上午11:24.
 */
public class ConstantMethodRefInfo extends AbstractConstantInfo {

    int classIndex;
    int nameAndTypeIndex;
    ConstantPool constantPool;

    public ConstantMethodRefInfo(ClassReader reader, ConstantPool constantPool) {
        super(reader);
        this.constantPool = constantPool;
    }

    public void parse() {
        classIndex = getReader().readTwoByte();
        nameAndTypeIndex = getReader().readTwoByte();
    }

    public int getClassIndex() {
        return classIndex;
    }

    public int getNameAndTypeIndex() {
        return nameAndTypeIndex;
    }

    public void setClassIndex(int classIndex) {
        this.classIndex = classIndex;
    }

    public void setNameAndTypeIndex(int nameAndTypeIndex) {
        this.nameAndTypeIndex = nameAndTypeIndex;
    }

    public String getClassName() {
        return constantPool.getClassName(this.classIndex);
    }

    public String[] getNameAndDescriptor() {
        return constantPool.getNameAndType(this.nameAndTypeIndex);
    }


}
